<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('试卷列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>

                            <li>
                                <label>学科：</label>
                                <select name="subject" th:with="type=${@dict.getType('sc_subject_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('school:paper:edit')}]];
        var removeFlag = [[${@permission.hasPermi('school:paper:remove')}]];
        var subjectDatas = [[${@dict.getType('sc_subject_type')}]];
        var difficultyDatas = [[${@dict.getType('sc_exam_difficulty')}]];
        var statusDatas = [[${@dict.getType('sys_data_status')}]];
        var prefix = ctx + "student/paper";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "试卷",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: 'null',
                    visible: false
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'name', 
                    title: '名称'
                },
                {
                    field: 'subject',
                    title: '学科',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(subjectDatas, value);
                    }
                },
                {
                    field: 'gradeName',
                    title: '年级名称'
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="print(\'' + row.id + '\')"><i class="fa fa-print"></i>打印试卷</a> ');
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="printAnswer(\'' + row.id + '\')"><i class="fa fa-print"></i>打印答案</a> ');

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function printAnswer(id) {

            //$.operate.addUrl("answer");
            //$.modal.openTab("开始答题" , prefix + "/answer/"+id);

            window.open(prefix + "/answer/print/"+id,"打印答案");
        }
        function print(id) {

            //$.operate.addUrl("answer");
            window.open(prefix + "/print/"+id,"打印试卷");
        }
    </script>
</body>
</html>